﻿using Host;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AXImServer
{
    public class InvitationComponent : IComponents
    {
        public IInvitationService InvitationService { get; set; }

        /// <summary>
        /// 获取全部的邀请
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        [IComponentsMethod]
        public CallBackStatusData GetAllInvitation(string token)
        {
            long userid = LoginManager.GetInstance().GetUserIdByToken(token);
            if (userid == -1)
                return CallBackStatusDataEx.IdentityFailure();

            var items = InvitationService.GetAllInvitation(userid);
            return new CallBackStatusData<IEnumerable<Invitation>> { StatusCode = StatusCode.Success, Data = items };
        }
    }
}
